home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / AnimToFrames.pprx < prev    next >
Text File  |  1997-07-22  |  5KB  |  156 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1995-1997 Cloanto Italia srl */
  2.  
  3. /* $VER: AnimToFrames.pprx 1.3 */
  4.  
  5. /** ENG
  6.   This script converts the current animation into separate frames, creating
  7.   a file for each frame. A three-digit suffix after the user-specified
  8.   file name indicates the position of each frame in the animation, starting
  9.   from frame 1. For example, if the name "Animation" is selected, the first
  10.   frame will be saved as "Animation.001". If the base name contains one or
  11.   more consecutive "0" characters, they will be used and progressively
  12.   replaced to store the frame number (e.g. "Animation_000.pic" becomes
  13.   "Animation_001.pic", "Animation_002.pic", etc.).
  14.  
  15. */
  16.  
  17. /** DEU
  18.   Dieses Skript wandelt die aktuelle Animation in Einzelbilder um, wobei
  19.   für jedes Bild eine eigene Datei erstellt wird. Die Position eines
  20.   Bildes innerhalb der Gesamtanimation wird durch eine dreistellige
  21.   Dateiendung wiedergegeben, beginnend mit Bild 1. Beispiel: Wird als
  22.   Name "Animation" festgelegt, so erhält das als erstes gespeicherte
  23.   Einzelbild den Dateinamen "Animation.001". Wenn der Stamm des
  24.   Dateinamens eine oder mehrere aufeinanderfolgende Nullen "0" enthält,
  25.   werden diese zur Speicherung der Einzelbildnummer verwendet. Beispiel:
  26.   "Animation_000.pic" wird zu "Animation_001.pic", "Animation_002.pic", usw.
  27. */
  28.  
  29. /** ITA
  30.   Questo script suddivide l'animazione attuale nei suoi singoli fotogrammi,
  31.   creando un file per ciascun fotogramma. Un suffisso a tre cifre presente
  32.   dopo il nome specificato dall'utente indica la posizione di ciascun
  33.   fotogramma all'interno dell'animazione, iniziando dal fotogramma 1. Ad
  34.   esempio, se si sceglie il nome "Animazione", il primo fotogramma sarà salvato
  35.   come "Animazione.001". Se il nome di base del file contiene uno o più
  36.   caratteri "0" consecutivi, essi saranno usati e progressivamente
  37.   incrementati per immagazzinare il numero di fotogramma (ad esempio
  38.   "Animation_000.pic" diventa "Animation_001.pic", "Animation_002.pic", ecc.).
  39. */
  40.  
  41. IF ARG(1, EXISTS) THEN
  42.     PARSE ARG PPPORT
  43. ELSE
  44.     PPPORT = 'PPAINT'
  45.  
  46. IF ~SHOW('P', PPPORT) THEN DO
  47.     IF EXISTS('PPaint:PPaint') THEN DO
  48.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  49.         DO 30 WHILE ~SHOW('P',PPPORT)
  50.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  51.         END
  52.     END
  53.     ELSE DO
  54.         SAY "Personal Paint could not be loaded."
  55.         EXIT 10
  56.     END
  57. END
  58.  
  59. IF ~SHOW('P', PPPORT) THEN DO
  60.     SAY 'Personal Paint Rexx port could not be opened'
  61.     EXIT 10
  62. END
  63.  
  64. ADDRESS VALUE PPPORT
  65. OPTIONS RESULTS
  66. OPTIONS FAILAT 10000
  67.  
  68. Get 'LANG'
  69. IF RESULT = 1 THEN DO        /* Deutsch */
  70.     txt_req_load      = 'Animation auswählen'
  71.     txt_req_sel       = 'Format und Namensstamm auswählen'
  72.     txt_err_abort     = 'Speichervorgang wurde abgebrochen'
  73.     txt_err_save      = 'Fehler beim Speichern: '
  74.     txt_err_oldclient = 'Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich'
  75. END
  76. ELSE IF RESULT = 2 THEN DO    /* Italiano */
  77.     txt_req_load      = 'Selezionare animazione'
  78.     txt_req_sel       = 'Selezionare formato e nome'
  79.     txt_err_abort     = 'Operazione annullata'
  80.     txt_err_save      = 'Errore nella scrittura: '
  81.     txt_err_oldclient = 'Questa procedura richiede_una versione più recente_di Personal Paint'
  82. END
  83. ELSE DO                /* English */
  84.     txt_req_load      = 'Select Animation'
  85.     txt_req_sel       = 'Select Format and Root Name'
  86.     txt_err_abort     = 'User abort during save'
  87.     txt_err_save      = 'Error during save: '
  88.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  89. END
  90.  
  91. Version 'REXX'
  92. IF RESULT < 7 THEN DO
  93.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  94.     EXIT 10
  95. END
  96.  
  97. LockGUI
  98. GetFrames
  99. frames = RESULT
  100. IF frames = 0 THEN DO
  101.     RequestFile '"'txt_req_load'"'
  102.     IF RC = 0 THEN DO
  103.         LoadAnimation RESULT 'NEW'
  104.         GetFrames
  105.         frames = RESULT
  106.     END
  107. END
  108. IF frames > 0 THEN DO
  109.     RequestFile '"'txt_req_sel'" SAVEMODE LISTFORMATS FORCE'
  110.     IF RC = 0 THEN DO
  111.         savedata = RESULT
  112.         endf = INDEX(savedata, '"', 2)
  113.         filename = SUBSTR(savedata, 2, endf - 2)
  114.         filedata = SUBSTR(savedata, endf + 1)
  115.  
  116.         npos1 = INDEX(filename, '0')
  117.         IF npos1 > 0 THEN DO
  118.             ndigits = 1
  119.             fnlen = LENGTH(filename)
  120.             DO npos = npos1 + 1 TO fnlen
  121.                 IF SUBSTR(filename, npos, 1) = '0' THEN
  122.                     ndigits = ndigits + 1
  123.                 ELSE
  124.                     LEAVE
  125.             END
  126.         END
  127.  
  128.         GetFramePosition
  129.         savepos = RESULT
  130.         errcode = 0
  131.         SetFramePosition 1
  132.         DO fnum = 1 TO frames
  133.             IF npos1 > 0 THEN
  134.                 fname = LEFT(filename, npos1 - 1) || RIGHT(fnum, ndigits, "0") || SUBSTR(filename, npos)
  135.             ELSE
  136.                 fname = filename || "." || RIGHT(fnum, 3, "0")
  137.  
  138.             SaveImage '"'fname'"'filedata 'FORCE QUIET'
  139.             IF RC ~= 0 THEN DO
  140.                 IF RC = 5 THEN
  141.                     errmess = txt_err_abort
  142.                 ELSE
  143.                     errmess = txt_err_save || RC
  144.                 errcode = RC
  145.                 LEAVE
  146.             END
  147.             SetFramePosition 'NEXT'
  148.         END
  149.         SetFramePosition savepos
  150.  
  151.         IF errcode > 0 THEN
  152.             RequestNotify 'PROMPT "'errmess'"'
  153.     END
  154. END
  155. UnlockGUI
  156.